package com.gorkr.bio.multi_thread;

import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author gorkr
 * @date 2022/05/31 00:06
 **/
public class Client {
    public static void main(String[] args) {
        try {
            // 1. 请求与服务端的Socket对象连接
            Socket socket = new Socket("127.0.0.1",9999);
            // 2. 得到打一个打印流
            PrintStream ps = new PrintStream(socket.getOutputStream());
            // 3. 得到循环不断的发送消息给服务端
            Scanner sc = new Scanner(System.in);
            while (true){
                System.out.println("请说：");
                String msg = sc.nextLine();
                // 打印流输出消息
                ps.println(msg);
                ps.flush();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
    